package model;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
 * this class is to create an contact object with a list of information
 * @author Estelle
 *
 */
public final class Contact {
	private String firstName;
	private String lastName;
	private String homeAddress;
	private String companyAddress;
	private String homePage;
	private String email;
	private String groupe;
	private ArrayList<Integer> date = new ArrayList<Integer>();
	private String personalPhone; 
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * the constructor
	 * @param firstName
	 * @param lastName
	 * @param number
	 */
	public Contact( String firstName, String lastName, String number ){
		this.firstName = firstName.toLowerCase();
		this.lastName = lastName.toUpperCase();
		this.personalPhone = number;
		this.homeAddress= "homeAddress";
		this.companyAddress="companyAddress";
		this.homePage="homePage";
		this.email="email";
		this.groupe ="groupe";
		this.updateDate();
	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * the default constructor
	 */
	public Contact(){
		this.firstName = "Undefined";
		this.lastName = "Undefined";
		this.personalPhone = "Undefined";
		this.homeAddress= "Undefined";
		this.companyAddress="Undefined";
		this.homePage="Undefined";
		this.email="Undefined";
		this.groupe ="groupe";

	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * a function to see if the contact is empty
	 * @return
	 */
	public boolean emptyContact(){
		
		if(!firstName.equals("Undefined") ) return false;
		if(!lastName.equals("Undefined")) return false;
		if(!personalPhone.equals("Undefined")) return false;
		if(!homeAddress.equals("Undefined")) return false;
		if(!companyAddress.equals("Undefined")) return false;
		if(!homePage.equals("Undefined")) return false;
		if(!email.equals("Undefined")) return false;
		if(!groupe.equals("Undefined")) return false;
		
		return true;
	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * to check if two contact are equals
	 * @param con
	 * @return
	 */
	public boolean isEqual(Contact con){
		
		if(!firstName.equals(con.getFirstName()) ) return false;
		if(!lastName.equals(con.getLastName())) return false;
		if(!personalPhone.equals(con.getPersonalPhone())) return false;
		if(!homeAddress.equals(con.getHomeAddress())) return false;
		if(!companyAddress.equals(con.getCompanyAddress())) return false;
		if(!homePage.equals(con.getHomePage())) return false;
		if(!email.equals(con.getEmail())) return false;
		if(!groupe.equals(con.getGroupe())) return false;
		
		return true;
	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * to update and storage the date of the creation of a contact in ArrayList of integer
	 */
	public void updateDate(){
		
		GregorianCalendar calendar = new GregorianCalendar();
		
		date.add(calendar.get(Calendar.YEAR));
		date.add(calendar.get(Calendar.MONTH));
		date.add(calendar.get(Calendar.DAY_OF_MONTH));
		date.add(calendar.get(Calendar.HOUR_OF_DAY));
		date.add(calendar.get(Calendar.MINUTE));
    	
	}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * to reset a contact with a other sent as parameter
	 * @param newCon
	 */
	public void copyContact(Contact newCon){
		
		this.firstName = newCon.getFirstName();
		this.lastName = newCon.getLastName();
		this.homeAddress= newCon.getHomeAddress();
		this.companyAddress=newCon.getCompanyAddress();
		this.homePage=newCon.getHomePage();
		this.email=newCon.getEmail();
		this.personalPhone=newCon.getPersonalPhone();
		this.groupe=newCon.getGroupe();
		this.date=newCon.getDate();
		
		}
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * to print some information about the contact in the console
	 */
	public void printContact(){
		System.out.println("Name :" + firstName);
		System.out.println("last :" + lastName);
		System.out.println("groupe :" + groupe);
		
	}
	
//--------------------------------------------------------------------------------------------------------------------------------------------------------
	/**
	 * getter and setter of the class
	 * @return
	 */
	
	public String getHomeAddress() {
		return homeAddress;
	}

	public void setHomeAddress(String homeAddress) {
		this.homeAddress = homeAddress;
	}

	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}

	public String getHomePage() {
		return homePage;
	}

	public void setHomePage(String homePage) {
		this.homePage = homePage;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPersonalPhone() {
		return personalPhone;
	}

	public void setPersonalPhone(String personalPhone) {
		this.personalPhone = personalPhone;
	}

	public String getGroupe() {
		return groupe;
	}

	public void setGroupe(String groupe) {
		this.groupe = groupe.toLowerCase();
	}
	
	public ArrayList<Integer> getDate() {
		return date;
	}

	public void setDate(ArrayList<Integer> date) {
		this.date = date;
	}
}
